package com.gf.framework.rabbitmq.model;

import lombok.*;

/**
 * @author gaofei
 * @date 2022/6/9 19:46
 */
@Data
@NoArgsConstructor
@Builder
public class ExchangeInfo {
    private String name;

    private ExchangeType type = ExchangeType.DIRECT;

    /**
     * 是否持久化
     */
    private Boolean durable = true;

    /**
     * 没有消费者后自动删除
     */
    private Boolean autoDelete = false;

    /**
     * 备用交换机，路由不到的数据会转发到此交换机
     */
    private String alternateExchange;

    public ExchangeInfo(String name) {
        this(name, ExchangeType.DIRECT);
    }

    public ExchangeInfo(String name, ExchangeType exchangeType) {
        this(name, exchangeType, true);
    }

    public ExchangeInfo(String name, ExchangeType exchangeType, Boolean durable) {
        this(name, exchangeType, durable, false);
    }

    public ExchangeInfo(String name, ExchangeType exchangeType, Boolean durable, Boolean autoDelete) {
        this(name, exchangeType, durable, autoDelete, null);
    }

    public ExchangeInfo(String name, ExchangeType exchangeType, Boolean durable, Boolean autoDelete, String alternateExchange) {
        setName(name);
        setType(exchangeType);
        setDurable(durable);
        setAutoDelete(autoDelete);
        setAlternateExchange(alternateExchange);
    }
}
